package job04;

import java.io.IOException;

import org.apache.hadoop.io.IntWritable;
import org.apache.hadoop.io.NullWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Reducer;
import org.apache.hadoop.mapreduce.Reducer.Context;

import job01.TProperties;

public class CountUvReducer extends Reducer<Text, IntWritable, NullWritable, Text> {
	private IntWritable cnt = new IntWritable();
	private Text result = new Text();
	private Text nkey = new Text();
	public void reduce(Text key, Iterable<IntWritable> values, Context context) throws IOException, InterruptedException {
		int sumPv = 0;
		int sumUv = 0;
		for (IntWritable val : values) {
			sumUv += 1;
			sumPv += val.get();
		}
		String tmp = key + TProperties.getValue("outfilesplit") + sumUv + TProperties.getValue("outfilesplit") + sumPv;
		result.set(tmp);
		context.write(NullWritable.get(), result);
	}
}
